<?php

require_once("../../controllers/init.php");
require_once($FILE_SYSTEM_ROOT."/controllers/authentication.php");

$personID = 0;
if (isset($_POST['personID']))
	$personID = $_POST['personID'];

$person = new Person($personID);


$allGroups = new Groups();
$arrAllGroups = $allGroups->getGroups();

$arrSelectedGroups = $person->getGroups();

//print_r($arrSelectedGroups);
//echo"\n";
//print_r($arrAllGroups);

$arrAvailableGroups = array();

foreach($arrAllGroups as $index => $group)
{
//	print "Checking if ".$index." is in array";
	if (!in_array($index,$arrSelectedGroups))
		$arrAvailableGroups[$index]=$group;
}

// print_r($arrAvailableGroups);

$grouplist = "";

foreach($arrAvailableGroups as $index => $group)
{
	$grouplist .= "<div class = \"people-edit-addgroup-group\" ";
	$grouplist .= "id=people-edit-addgroup-group-".$index.">";
	$grouplist .= $group;
	$grouplist .= "</div>";
}

?>

<div id="people-edit-addgroup-heading">Add Group</div>

<?php echo $grouplist; ?>

<div id="people-edit-addgroup-cancel">Cancel</div>
